var StartMainLayer03 = cc.Layer.extend({
	lead:null,
	real:null,
	versions:null,
	ctor:function () {
		this._super();
		this.loadStartButton();
		this.loadStartButtonParticle();
		return true;
	},
	loadBack: function(menu){
		this.backItem = new cc.MenuItemImage("#button/back.png","#button/back.png",this.eventMenuCallback,this);
		menu.addChild(this.backItem, 1, TAG_CLOSE);
		this.backItem.setPosition(984, 40);
	},
	loadStartButton : function(){
		this.lead = new cc.MenuItemImage(
				"#home_lead1.png",
				"#home_lead2.png",
				this.eventMenuCallback,this);
		this.lead.setPosition(gg.width * 0.25, gg.height * 0.4);

		this.real =  new cc.MenuItemImage(
				"#home_real1.png",
				"#home_real2.png",
				this.eventMenuCallback,this);
		this.real.setPosition(gg.width * 0.75, gg.height * 0.4);

		var menu = new cc.Menu();
		this.addChild(menu);
		menu.setPosition(0, 0);
		menu.addChild(this.lead);
		menu.addChild(this.real);
		this.loadBack(menu);
	},
	//加载特效
	loadLightParticle:function(){
		//cc.ParticleSystem粒子系统基类
		var light=new cc.ParticleSystem(res_start03.particle_p);
		light.setPosition(-50,gg.height+50);
		this.addChild(light);
	},
	loadStartButtonParticle : function(){
		//粒子系统基类cc.ParticleSystem
		var lead_node = new cc.ParticleSystem(res_start03.follow_p);
		this.addChild(lead_node);
		lead_node.setPosition(this.lead.x - this.lead.width / 2, this.lead.y - this.lead.height / 2);
		var action = this.getFollowAction(10, this.lead);
		lead_node.runAction(action);

		var real_node = new cc.ParticleSystem(res_start03.follow_p);
		this.addChild(real_node);
		real_node.setPosition(this.real.x - this.real.width / 2, this.real.y - this.real.height / 2);
		var action = this.getFollowAction(10, this.real);
		real_node.runAction(action);
	},
	getFollowAction : function(stretch, node){
		var width = node.width;
		var height = node.height;
		//cc.bezierBy该动作按照贝塞尔曲线路径将目标移动到指定的位置。 相对于它的运动。
		var bezier1 = [cc.p(-stretch, 0), cc.p(-stretch, height), cc.p(0, height)];
		var bezierBy1 = cc.bezierBy(0.6, bezier1);
		var move1 = new cc.moveBy(0.7, cc.p(width, 0));

		var bezier2 = [cc.p(stretch, 0), cc.p(stretch, -height), cc.p(0, -height)];
		var bezierBy2 = cc.bezierBy(0.6, bezier2);
		var move2 = new cc.moveBy(0.7, cc.p(-width, 0));

		var action = cc.sequence(bezierBy1, move1, bezierBy2, move2).repeatForever();
		return action;
	},
	eventMenuCallback:function(pSend){
		switch(pSend){
		case this.lead:
			cc.log("进入引导模式");
			gg.teach_type = TAG_LEAD;
			this.runPlay();
			break;
		case this.real:
			cc.log("进入实战模式");
			gg.teach_type = TAG_REAL;
			this.runPlay();
			break;
		case this.backItem:
			ch.howToGo(OP_TYPE_BACK);
			break;
		}
	},
	runPlay:function(){
		if(loadResHand.checkLoadFinish(TAG_EXP_03, TAG_LOAD_TYPE_RUN)){
			$.runScene(new PlayScene());	
		}  else {
			cc.LoaderScene.preload(g_resources_play03, function () {
				$.runScene(new PlayScene());
			}, this);
		}
	}
});
